package org.xhnews.ui;

import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.decor.BackgroundFactory;

public class TitleField extends HorizontalFieldManager {
	private FCLabelField _title;
	public TitleField(String strTitle) {
		super(HorizontalFieldManager.USE_ALL_WIDTH
				| HorizontalFieldManager.HORIZONTAL_SCROLL);
		setBackground(BackgroundFactory
				.createSolidBackground(Color.BLACK));
		_title=new FCLabelField(strTitle,LabelField.NON_FOCUSABLE);
		add(_title);	
	}
	public TitleField() {
		super(HorizontalFieldManager.USE_ALL_WIDTH
				| HorizontalFieldManager.HORIZONTAL_SCROLL);
		setBackground(BackgroundFactory
				.createSolidBackground(Color.BLACK));
		_title=new FCLabelField("",LabelField.NON_FOCUSABLE);
		add(_title);	
	}
    public void setText(String text){
    	_title.setText(text);
    }
	class FCLabelField extends LabelField {
		public FCLabelField(Object text, long style) {
			super(text, style);
		}

		private int mFontColor = Color.WHITE;

		public void setFontColor(int fontColor) {
			mFontColor = fontColor;
		}

		protected void paint(Graphics graphics) {
			if (-1 != mFontColor)
				graphics.setColor(mFontColor);
			super.paint(graphics);
		}
	}
}
